﻿using System;
using System.Collections.Generic;
using iTunesLib;

namespace iTunes.Scrubber.BaseClasses
{
    public abstract class MediaBase : Interfaces.IMediaItem, IComparable, IComparable<MediaBase>, IComparer<MediaBase>
    {
        public IITFileOrCDTrack LocalTrack { get { return DataSources.ITunesSource.Instance.GetTrackByPersistentID(this.PersistentID) as IITFileOrCDTrack; } }

        public UInt64 PersistentID { get; set; }

        public String IMDB_ID { get; set; }

        public Int32? Year { get; set; }

        public String Location { get; set; }

        public String Title { get; set; }
        public String Comments { get; set; }
        public String Genre { get; set; }

        public Enums.MediaKindEnum MediaKind { get; set; }

        public DateTime? DateModified { get; set; }
        public DateTime? DateAdded { get; set; }

        private Boolean _isDirty = false;
        public Boolean IsDirty { get { return this._isDirty; } set { this._isDirty = value; } }

        #region IComparable and IComparer Implementation

        public Int32 CompareTo(MediaBase other) { return this.PersistentID.CompareTo(other.PersistentID); }

        public Int32 Compare(MediaBase x, MediaBase y) { return x.PersistentID.CompareTo(y.PersistentID); }

        public Int32 CompareTo(Object obj) { return this.PersistentID.CompareTo((obj as MediaBase).PersistentID); }

        #endregion

        /*
        internal static Enums.MediaKindEnum GetKind<T>() where T : IMediaItem
        {
            if (typeof(T) == typeof(TVShowItem))
                return Enums.MediaKindEnum.TVShow;
            if (typeof(T) == typeof(MovieItem))
                return Enums.MediaKindEnum.Movie;
            if (typeof(T) == typeof(MusicItem))
                return Enums.MediaKindEnum.Music;
            if (typeof(T) == typeof(MusicVideoItem))
                return Enums.MediaKindEnum.MusicVideo;
            return Enums.MediaKindEnum.None;
        }
        */
    }

    public abstract class MediaBase<T> : MediaBase where T : MediaBase<T>
    {
        public abstract T UpdateMetaData();
    }
}